package com.ljsw.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;

import com.ljsw.activity.R;
import com.ljsw.util.DialogListener;
import com.ljsw.view.HuaBanView;

public class WritePadDialog extends Dialog {

	Context context;
	LayoutParams p;
	DialogListener dialogListener;
	String strPath; // 背景图片路径

	public WritePadDialog(Context context, DialogListener dialogListener,
			String path) {
		super(context);
		this.context = context;
		this.dialogListener = dialogListener;
		this.strPath = path;
	}

	public WritePadDialog(Context context) {
		super(context);
		this.context = context;
	}

	static final int BACKGROUND_COLOR = Color.WHITE;

	static final int BRUSH_COLOR = Color.BLACK;

	HuaBanView mView;

	int mColorIndex;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.dialog_write_pad);

		p = getWindow().getAttributes();
		p.height = 740;
		p.width = 520;
		getWindow().setAttributes(p);
		Button btnClear = (Button) findViewById(R.id.tablet_clear);
		mView = (HuaBanView) findViewById(R.id.huaBanView1);
		mView.setBackgroud(strPath);

		btnClear.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				mView.clearScreen();
			}
		});

		Button btnOk = (Button) findViewById(R.id.tablet_ok);
		btnOk.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				dialogListener.refreshActivity(mView.getCachebBitmap());
				dismiss();
			}
		});

		Button btnCancel = (Button) findViewById(R.id.tablet_cancel);
		btnCancel.setOnClickListener(new View.OnClickListener() {

			public void onClick(View v) {
				dismiss();
			}
		});
	}

}
